# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  helper :all # include all helpers, all the time
  protect_from_forgery # See ActionController::RequestForgeryProtection for details

  # Scrub sensitive parameters from your log
  # filter_parameter_logging :password
  
  # won't catch all errors -- see http://wiki.rubyonrails.com/rails/pages/HowtoConfigureTheErrorPageForYourRailsApp
  def rescue_action_in_public(exception)
    case exception.class.to_s
    when 'ActiveRecord::RecordNotFound', 'ActionController::UnknownAction'
      logger.fatal "404 handling"
      render(:file   => "#{RAILS_ROOT}/public/404.html",
      :status => '404 Not Found',
      :layout => 'master')
    else
      logger.fatal exception.inspect
      render(:file   => "#{RAILS_ROOT}/public/500.html",
      :status => '500 Error',
      :layout => 'master')
      SystemNotifier.deliver_exception_notification(self, request, exception)
    end
  end
end
